package com.venus.pub.pubuser.service.impl;

import java.util.List;

import com.venus.common.service.impl.BaseServiceImpl;
import com.venus.model.PubUserVO;
import com.venus.pub.pubuser.dao.IPubUserDAO;
import com.venus.pub.pubuser.service.IPubUserService;

public class PubUserServiceImpl extends BaseServiceImpl implements IPubUserService {

	private IPubUserDAO pubUserDAO ;

	public void setPubUserDAO(IPubUserDAO pubUserDAO) {
		this.pubUserDAO = pubUserDAO;
	}
	
	public void deletePubuser(PubUserVO pubUser) {
		this.pubUserDAO.deleteModel(pubUser);
	}

	public PubUserVO findPubUserVO(Integer iPubUserId) {
		return this.pubUserDAO.getModel(PubUserVO.class, iPubUserId);
	}

	public void saveOrUpdatePubUser(PubUserVO pubUser) {
		this.pubUserDAO.saveOrUpdateModel(pubUser);
	}
	
	@SuppressWarnings("unchecked")
	public PubUserVO login(String strUserName ,String strPassword){
		StringBuffer sb = new StringBuffer(128);
		sb.append(" FROM PubUserVO as PubUserVO WHERE 1=1");
		sb.append(" AND PubUserVO.userName='");
		sb.append(strUserName);
		sb.append("'");
		sb.append(" AND PubUserVO.password='");
		sb.append(strPassword);
		sb.append("'");
		List<PubUserVO> lstPubUserVO = this.pubUserDAO.exeHql(sb.toString());
		if(lstPubUserVO!=null && lstPubUserVO.size()>0){
			return lstPubUserVO.get(0);
		}else{
			return null;
		}
	}
	
}
